package com.qf.flash.ui.home.adapter;

import android.app.Activity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.qf.flash.R;
import com.qf.flash.http.response.PlayTypeBean;
import com.qf.flash.http.response.StrategyTopBean;
import com.qf.flashlib.adapter.BaseRViewItem;
import com.qf.flashlib.adapter.RVAdapter;
import com.qf.flashlib.adapter.RViewHolder;

public class StrategyTopItem extends BaseRViewItem<Object> {
    private Activity context;

    public StrategyTopItem(Activity context) {
        this.context = context;
    }

    @Override
    public boolean isItemView(Object entity, int position) {
        return entity instanceof StrategyTopBean;

    }

    @Override
    public int getItemLayout() {
        return R.layout.item_strategy_top;
    }

    @Override
    public void convert(RViewHolder holder, Object entity, int position, int itemSize) {
        StrategyTopBean topBean = (StrategyTopBean) entity;
        RecyclerView rvType = holder.getView(R.id.rv_type);
        RVAdapter<PlayTypeBean> mTypeAdapter = new RVAdapter<>(new PlayTypeItem());
        rvType.setAdapter(mTypeAdapter);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
        linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        rvType.setLayoutManager(linearLayoutManager);
        mTypeAdapter.setDatas(topBean.getPlayTypeBeans());
    }
}
